package o;

import android.util.DisplayMetrics;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.ActivityChooserView.ActivityChooserViewAdapter;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.i;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.n;
import androidx.recyclerview.widget.RecyclerView.q;
import androidx.recyclerview.widget.RecyclerView.q.c;
import androidx.recyclerview.widget.RecyclerView.q.e;
import androidx.recyclerview.widget.RecyclerView.t;

public abstract class mu extends i {
    private Scroller ˊ;
    RecyclerView ˏ;
    private final n ॱ = new n(this) {
        final /* synthetic */ mu ˏ;
        boolean ॱ = false;

        {
            this.ˏ = r2;
        }

        public void ˎ(RecyclerView recyclerView, int i) {
            super.ˎ(recyclerView, i);
            if (i == 0 && this.ॱ) {
                this.ॱ = false;
                this.ˏ.ˏ();
            }
        }

        public void ˊ(RecyclerView recyclerView, int i, int i2) {
            if (i != 0 || i2 != 0) {
                this.ॱ = true;
            }
        }
    };

    public abstract int ˏ(j jVar, int i, int i2);

    @Nullable
    public abstract int[] ˏ(@NonNull j jVar, @NonNull View view);

    @Nullable
    public abstract View ॱ(j jVar);

    public boolean ˎ(int i, int i2) {
        j ʻ = this.ˏ.ʻ();
        if (ʻ == null || this.ˏ.ˋ() == null) {
            return false;
        }
        int ˋॱ = this.ˏ.ˋॱ();
        if ((Math.abs(i2) > ˋॱ || Math.abs(i) > ˋॱ) && ˋ(ʻ, i, i2)) {
            return true;
        }
        return false;
    }

    public void ˏ(@Nullable RecyclerView recyclerView) throws IllegalStateException {
        if (this.ˏ != recyclerView) {
            if (this.ˏ != null) {
                ॱ();
            }
            this.ˏ = recyclerView;
            if (this.ˏ != null) {
                ˋ();
                this.ˊ = new Scroller(this.ˏ.getContext(), new DecelerateInterpolator());
                ˏ();
            }
        }
    }

    private void ˋ() throws IllegalStateException {
        if (this.ˏ.ˊ() != null) {
            throw new IllegalStateException("An instance of OnFlingListener already set.");
        }
        this.ˏ.ॱ(this.ॱ);
        this.ˏ.setOnFlingListener(this);
    }

    private void ॱ() {
        this.ˏ.ˏ(this.ॱ);
        this.ˏ.setOnFlingListener(null);
    }

    public int[] ˏ(int i, int i2) {
        r9 = new int[2];
        this.ˊ.fling(0, 0, i, i2, Integer.MIN_VALUE, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED, Integer.MIN_VALUE, ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED);
        r9[0] = this.ˊ.getFinalX();
        r9[1] = this.ˊ.getFinalY();
        return r9;
    }

    private boolean ˋ(@NonNull j jVar, int i, int i2) {
        if (!(jVar instanceof c)) {
            return false;
        }
        q ˏ = ˏ(jVar);
        if (ˏ == null) {
            return false;
        }
        int ˏ2 = ˏ(jVar, i, i2);
        if (ˏ2 == -1) {
            return false;
        }
        ˏ.ॱ(ˏ2);
        jVar.ॱ(ˏ);
        return true;
    }

    void ˏ() {
        if (this.ˏ != null) {
            j ʻ = this.ˏ.ʻ();
            if (ʻ != null) {
                View ॱ = ॱ(ʻ);
                if (ॱ != null) {
                    int[] ˏ = ˏ(ʻ, ॱ);
                    if (ˏ[0] != 0 || ˏ[1] != 0) {
                        this.ˏ.ˊ(ˏ[0], ˏ[1]);
                    }
                }
            }
        }
    }

    @Nullable
    protected q ˏ(j jVar) {
        return ˋ(jVar);
    }

    @Deprecated
    @Nullable
    protected mh ˋ(j jVar) {
        if (jVar instanceof c) {
            return new mh(this, this.ˏ.getContext()) {
                final /* synthetic */ mu ᐝ;

                public void ˋ(View view, t tVar, e eVar) {
                    if (this.ᐝ.ˏ != null) {
                        int[] ˏ = this.ᐝ.ˏ(this.ᐝ.ˏ.ʻ(), view);
                        int i = ˏ[0];
                        int i2 = ˏ[1];
                        int ˎ = ˎ(Math.max(Math.abs(i), Math.abs(i2)));
                        if (ˎ > 0) {
                            eVar.ˏ(i, i2, ˎ, this.ˎ);
                        }
                    }
                }

                protected float ˋ(DisplayMetrics displayMetrics) {
                    return 100.0f / ((float) displayMetrics.densityDpi);
                }
            };
        }
        return null;
    }
}
